const TokenKey = "XMGIS.AuthToken";
export function getToken() {
  if (typeof window !== "undefined") {
    const token = localStorage.getItem(TokenKey);
    if (token !== TokenKey) {
      return token;
    } else return null;
  } else return "1";
}

export function setToken(token: any) {
  if (token && token !== TokenKey) localStorage.setItem(TokenKey, token);
}

export function clearToken() {
  localStorage.clear();
}
const UserIdKey = "userId";
export function getUserId() {
  const userId = localStorage.getItem(UserIdKey);
  return userId || "";
}

export function setUserId(userId: any) {
  if (userId) localStorage.setItem(UserIdKey, userId);
}
1;

/*******视频监控token********/
const AccessToken = "VIDEO.AuthToken";
export function getAccessToken() {
  if (typeof window !== "undefined") {
    const token = localStorage.getItem(AccessToken);
    if (token !== AccessToken) {
      return token;
    } else return null;
  } else return "1";
}

export function setAccessToken(token: any) {
  if (token && token !== AccessToken) localStorage.setItem(AccessToken, token);
}
